<?php
include "../../fun.php";
isLogin();
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统项目设置</title>
    <link rel="stylesheet" href="/static/layui-v2.6.8/layui/css/layui.css">
    <script src="/static/layui-v2.6.8/layui/layui.js"></script>
</head>

<body>
    <div style="padding-top:10px">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">公司名称</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="company" required  lay-verify="required" placeholder="请输入公司名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">公司logo</label>
                <div class="layui-input-block" style="width:500px">
                    <button type="button" class="layui-btn" id="pic">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                    <style>
                        img{max-width:100px;}
                    </style>
                    <input type="hidden" name="pic">
                    <div id="picInfo" style="display:inline-block;"></div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="contactUs" required  lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="phone" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系人</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="contact" required  lay-verify="required" placeholder="请输入联系人" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">QQ</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="QQ" required  lay-verify="required" placeholder="请输入QQ号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">email</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="email" required  lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="address" required  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">版权</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="copyright" required  lay-verify="required" placeholder="请输入版权" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备案号</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="recorderNumber" required  lay-verify="required" placeholder="请输入备案号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                </div>
            </div>
        </form>
    </div>
    
    <script>
        layui.use(['form','upload','jquery'], function(){
            var form = layui.form//表单提交
            ,upload = layui.upload//文件上传
            ,$=layui.jquery;
  
            //监听提交
            form.on('submit(formDemo)', function(data){
                // layer.msg(JSON.stringify(data.field));
                $.ajax({
                    method:"post",
                    url: "./save.php",
                    data: data.field,
                    dataType: "json",
                    success: function (res) {
                        if (res.code==0) {
                            layer.msg(res.msg,{icon:1,time:2000},function () {
                                parent.location.href='./index.php';
                            })
                        }
                    }
                });
                return false;
            });

            //执行文件上传实例
            var uploadInst = upload.render({
                elem: '#pic' //绑定元素
                ,url: '../upload.php' //上传接口
                ,done: function(res){
                //上传完毕回调
                    if (res.code==0) {
                        $("input[name='pic']").val(res.pic);
                        var html=`<img src="../upload/${res.pic}" alt="">`;
                        $("#picInfo").html(html);
                    }
                }
                ,error: function(){
                //请求异常回调
                }
            });
        });
    </script>
</body>

</html>

</html>